Skip to content

gh-155053: Fix GenericAlias crash on OOM - #155055

Open
BHUVANSH855 wants to merge 5 commits into
python:mainfrom
BHUVANSH855:investigate-genericalias-oom-null-decref
Open

gh-155053: Fix GenericAlias crash on OOM#155055
BHUVANSH855 wants to merge 5 commits into
python:mainfrom
BHUVANSH855:investigate-genericalias-oom-null-decref

Conversation

@BHUVANSH855

Copy link
Copy Markdown
Contributor

Summary

Fix a NULL dereference in Objects/genericaliasobject.c when tuple_extend()
fails during TypeVarTuple substitution under allocation failure.

When _PyTuple_Resize() fails, it clears its out-parameter, so subargs
becomes NULL. The error path in subs_tvars() must not call
Py_DECREF(subargs) and should instead propagate the MemoryError.

Also add a regression test covering the allocation-failure path using
_testcapi.set_nomemory() to ensure a MemoryError is raised instead of
crashing the interpreter.

Issue: gh-155053

Comment thread Lib/test/test_genericalias.py Outdated
Comment thread Objects/genericaliasobject.c
@bedevere-app

bedevere-app Bot commented Aug 2, 2026

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@BHUVANSH855
BHUVANSH855 requested a review from picnixz August 2, 2026 13:28
@BHUVANSH855

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

@bedevere-app

bedevere-app Bot commented Aug 2, 2026

Copy link
Copy Markdown

Thanks for making the requested changes!

@picnixz: please review the changes made to this pull request.

Comment thread Misc/NEWS.d/next/Core_and_Builtins/2026-08-01-19-17-56.gh-issue-155053.sxmlTO.rst Outdated
Comment thread Objects/genericaliasobject.c Outdated
@BHUVANSH855
BHUVANSH855 requested a review from picnixz August 2, 2026 15:37
Comment thread Objects/genericaliasobject.c
@BHUVANSH855
BHUVANSH855 requested a review from picnixz August 2, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants